package cn.ht.callableDemo;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

class MyThread implements Callable<Integer>{

    @Override
    public Integer call() throws Exception {
        System.out.println("==================>come in callable!");
        return 1024;
    }
}



public class CallableDemo {

    public static void main(String[] args) throws ExecutionException, InterruptedException {
        FutureTask<Integer> futureTask = new FutureTask<>(new MyThread());
        Thread thread = new Thread(futureTask,"AAA");
        thread.start();
        //futureTask.get()建议放在最后
        System.out.println(futureTask.get());
    }

}
